﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using System.Drawing;
using ImageConverter;
using Shared;
using System.IO;
using System.Windows.Forms;
using System.Security.Cryptography;


namespace DAL
{
   class ShopContextInitializer : DropCreateDatabaseAlways<ShopContext>
    {
        protected override void Seed (ShopContext context)
        {            
            context.Users.Add(new User { Email = " ", Password = "admin" });
            context.Users.Add(new User { Email = "belich@mail.com", Password = "123456",
            FirstName="Valeriy", LastName="Belich"});

            ProductCategory pc1= new ProductCategory
            {
                Name = "Crossovers"                
            };
            context.ProductCategories.Add(pc1);
            context.Products.Add(new Product
            {
                Category= "Crossovers",
                Name = "Honda CRV",
                Price = 25000,
                Image = ImageConvert.imageToByteArray(Image.FromFile(Application.StartupPath+@"\PicturesForShop\HondaCRV.bmp"))             
            });

            context.Products.Add(new Product
            {
                Category = "Crossovers",
                Name = "Mitsubishi Outlander",
                Price = 24000,
                Image = ImageConvert.imageToByteArray(Image.FromFile(Application.StartupPath + @"\PicturesForShop\Mitsu.bmp"))              
            });

            ProductCategory pc2 = new ProductCategory
            {
                Name = "Business"
            };
            context.ProductCategories.Add(pc2);

            ProductCategory pc3 = new ProductCategory
            {
                Name = "Hatchbacks"
            };
            context.ProductCategories.Add(pc3);

            context.Products.Add(new Product
            {
                Name = "Mercedes Benz S600",
                Price = 89000,
                Image = ImageConvert.imageToByteArray(Image.FromFile(Application.StartupPath + @"\PicturesForShop\mers.bmp")),
                Category = "Business"
            });

            context.Products.Add(new Product
            {
                Name = "Lexus IS460",
                Price = 70000,
                Image = ImageConvert.imageToByteArray(Image.FromFile(Application.StartupPath + @"\PicturesForShop\lexus.bmp")),
                Category = "Business"
            });

            context.Products.Add(new Product
            {
                Name = "Seat Ibiza",
                Price = 16000,
                Image = ImageConvert.imageToByteArray(Image.FromFile(Application.StartupPath + @"\PicturesForShop\seat.bmp")),
                Category = "Hatchbacks"
            });

            
            context.Products.Add(new Product
            {
                Name = "ZAZ Forza",
                Price = 11000,  
                Image =ImageConvert.imageToByteArray(Image.FromFile(Application.StartupPath + @"\PicturesForShop\zaz.bmp")),         
                Category = "Hatchbacks"
            });
                    
            context.SaveChanges();
        }

        
    }
}
